<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class HorizonController extends Controller
{
    public function login(Request $request)
    {
        [$username, $password] = $request->fields(
            [
                'username' => 'required',
                'password' => 'required'
            ]
        );

        if (!$jwt_token = auth()->guard('web')->attempt(compact('username', 'password'))) {
            throw_e('账号密码错误');
        }

        return redirect('/horizon');
    }
}
